package storage;

import people.Enemy;

public class EnemyStorage {

	public static Enemy[] storage = new Enemy[50];

	public static void storeEnemy(Enemy enemy) {
		for (int i = 0; i < storage.length; i++) {
			if (storage[i] == null) {
				storage[i] = enemy;
				return;
			}
		}
	}

	public static void removeEnemy(Enemy enemy) {
		for (int i = 0; i < storage.length; i++) {
			if (storage[i] == enemy) {
				storage[i] = null;
				return;
			}
		}
	}
	
	public static Enemy findEnemyinXY(int x, int y) {
		for (int i = 0; i < storage.length; i++) {
			try {
				if (storage[i].x == x) {
					if (storage[i].y == y) {
						return storage[i];
					}
				}
			}
			catch (NullPointerException npe) {
				break;
			}
		}
		return null;
	}

	public int[] findXY(Enemy enemy) {
		int[] xy = new int[2];
		xy[0] = enemy.x;
		xy[1] = enemy.y;
		return xy;
	}
}
